﻿using System.Linq;
using System.Windows.Controls;
using System.Windows;
using EDMDesigner.Designer.Controls.Util;

namespace EDMDesigner.Designer.Controls.Mapping
{
    public partial class ComplexPropertiesMapping : UserControl
    {
        public ComplexPropertiesMapping()
        {
            InitializeComponent();
        }

        public UIBusiness.MSL.ComplexPropertiesMapping Mappings
        {
            get { return (UIBusiness.MSL.ComplexPropertiesMapping)GetValue(MappingsProperty); }
            set { SetValue(MappingsProperty, value); }
        }
        public static readonly DependencyProperty MappingsProperty =
            DependencyProperty.Register("Mappings", typeof(UIBusiness.MSL.ComplexPropertiesMapping), typeof(ComplexPropertiesMapping), new UIPropertyMetadata(null, (sender, e) => ((ComplexPropertiesMapping)sender).RefreshMappings())); 

        internal void RefreshMappings()
        {
            if (Mappings != null)
                complexPropertiesTreeViewItem.ItemsSource = Mappings.Mappings;
        }

        private bool _tpc;
        public bool TPC
        {
            get { return _tpc; }
            set
            {
                _tpc = value;
                Mappings.TPC = value;
                RefreshMappings();
            }
        }
    }
}
